#include <my_header.h>
// 传递地址
/* Usage: ./6_shared_stack3 */
void *threadFunc(void *arg)
{
    
    int *pval = (int *)arg;
    printf("I am child thread\n");
    // 传入参数 强转
    printf("child, val =%d\n", *pval);

    return NULL;
}
int main(void){                                  
    
    int val = 1000;  // 局部变量 栈空间

    pthread_t tid;
    int ret = pthread_create(&tid, NULL, threadFunc, 
                             &val);
    THREAD_ERROR_CHECK(ret, "pthread_create");

    
    // sleep(1);

    val = 2000;
    ret = pthread_create(&tid, NULL, threadFunc, &val);
    THREAD_ERROR_CHECK(ret, "pthread_create");
    // 虽然栈是私有的，但是其他线程依然有权限读写
    printf("I am main thread\n");
   
    sleep(1);
    return 0;
}


